package com.wbl.train.common.result;

/**
 * 统一的结果业务状态码定义枚举类 (异常信息状态码枚举类)
 * @author xlzhang
 */
public enum ResultCode {
    /**
     * 枚举项，注意同一类型的异常枚举项集中一起，不同的类型之间用空格分割
     */
    // 成功段0
    SUCCESS(200,"操作成功"),

    // 登录段1~50
    NEED_LOGIN(1,"需要登录后操作"),
    SYSTEM_USERNAME_NOT_EXISTS(2,"用户名不存在"),
    LOGIN_PASSWORD_ERROR(3,"密码错误"),
    AD_USER_DATA_NOT_EXIST(4,"后台管理用户不存在"),

    // TOKEN50~100
    TOKEN_INVALID(50,"无效的TOKEN"),
    TOKEN_EXPIRE(51,"TOKEN已过期"),
    TOKEN_REQUIRE(52,"TOKEN是必须的"),

    // SIGN验签 100~120
    SIGN_INVALID(100,"无效的SIGN"),
    SIG_TIMEOUT(101,"SIGN已过期"),

    // 参数错误 500~1000
    PARAM_REQUIRE(500,"缺少参数"),
    PARAM_INVALID(501,"无效参数"),
    PARAM_IMAGE_FORMAT_ERROR(502,"图片格式有误"),
    SERVER_ERROR(503,"服务器内部错误"),

    // 数据错误 1000~2000
    DATA_EXIST(1000,"数据已经存在"),
    AP_USER_DATA_NOT_EXIST(1001,"ApUser数据不存在"),
    DATA_NOT_EXIST(1002,"数据不存在"),
    ID_HAS_EXIST(1003,"主键已存在"),
    DATA_ERROR(1004,"数据错误"),

    // 业务错误 2000~3000
    PASSENGER_EXCEED_LIMIT(2001,"乘客数量超限"),
    INSUFFICIENT_REMAINING_TICKETS(2002,"余票不足"),
    ERROR_DB_BATCH(2003,"批量操作失败"),
    SEAT_QUANTITY_NOT_ENOUGH(2004,"座位数量不足"),
    TICKET_ERROR_UPDATE(2005,"余票详情更新失败"),
    TICKET_ERROR_SAVE(2005,"车票保存失败"),
    ORDER_ERROR_UPDATE(2005,"车票保存失败"),
    SAVE_TICKET_INFO_FAIL(2006,"保存购票信息失败"),
    SENTINEL_DEAL_BUY_TICKET(2007,"当前抢票人数过多，请稍后在试"),
    VALID_SK_TOKEN(2008,"令牌余量不足，票已卖光"),
    REDISSON_TRY_LOCK_FAIL(2009,"redisson加锁失败"),
    REDISSON_LOCK_EXCEPTION(2010,"redisson加锁发生异常"),
    CONFIRM_ORDER_SK_TOKEN(2011,"购票令牌数量不足"),


    // 数据错误 3000~3500
    NO_OPERATOR_AUTH(3000,"无权限操作"),
    NEED_ADMIN(3001,"需要管理员权限"),

    DATA_NOT_ALLOW(40001,"审核对象不存在"),
    DATA_UPDATE_ERROR(40002,"数据修改失败"),
    NO_HANDLER_FOUND(40401,"请求的资源不存在"),
    PARAM_VALID_ERROR(40501,"参数异常"),
    METHOD_NOT_SUPPORTED(40502,"请求方法不匹配"),
    MEDIA_TYPE_NOT_SUPPORTED(41501,"不支持的媒体类型"),

    SCHEDULE_CLASS_NOT_EXIST(50001,"任务类不存在"),
    SCHEDULE_DISPATCH_ERROR(50002,"调度异常"),
    TEXT_PARSE_ERROR(50003,"文本解析异常")
            ;

    int code;
    String errorMessage;

    ResultCode(int code, String errorMessage){
        this.code = code;
        this.errorMessage = errorMessage;
    }

    public int getCode() {
        return code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}